import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    selectedIndex: undefined,
    //数据结构
    students: [
      {
        id: 1,
        name: "小张",
        gender: "M",
        age: 18,
        ID: "",
        telephone: "",
        address: "",
        school: "清华大学",
        major: "",
        grade: "",
        //状态   -1--拒绝  0--进度中 1--通过
        status: 0,
        //进度条占比 (0--还没做操作，进行中  33--步骤一通过 66--步骤二通过  99--步骤三通过)
        schedule: 0,
      },
      {
        id: 2,
        name: "小康",
        gender: "F",
        age: 19,
        ID: "",
        telephone: "",
        address: "",
        school: "",
        major: "",
        grade: "",
        //状态
        status: 0,
        //进度条占比 (0--还没做操作，进行中  33--步骤一通过 66--步骤二通过  99--步骤三通过)
        schedule: 0,
      },
      {
        id: 3,
        name: "小王",
        gender: "M",
        age: 20,
        ID: "",
        telephone: "",
        address: "",
        school: "",
        major: "",
        grade: "",
        //状态
        status: 0,
        //进度条占比 (0--还没做操作，进行中  33--步骤一通过 66--步骤二通过  99--步骤三通过)
        schedule: 0,
      },
      {
        id: 4,
        name: "小党",
        gender: "F",
        age: 20,
        ID: "",
        telephone: "",
        address: "",
        school: "",
        major: "",
        grade: "",
        //状态
        status: 0,
        //进度条占比 (0--还没做操作，进行中  33--步骤一通过 66--步骤二通过  99--步骤三通过)
        schedule: 0,
      },
      {
        id: 5,
        name: "小施",
        gender: "M",
        age: 21,
        ID: "",
        telephone: "",
        address: "",
        school: "",
        major: "",
        grade: "",
        //状态
        status: 0,
        //进度条占比 (0--还没做操作，进行中  33--步骤一通过 66--步骤二通过  100--步骤三通过)
        schedule: 1,
      },
      {
        id: 6,
        name: "小段",
        gender: "F",
        age: 20,
        ID: "",
        telephone: "",
        address: "",
        school: "",
        major: "",
        grade: "",
        //状态
        status: 0,
        //进度条占比 (0--还没做操作，进行中  0--还未处理 1--步骤一通过  2--步骤二通过)
        schedule: 0,
      },
    ],
  },
  getters: {
    //选中的是哪一条数据
    selectedStudent: function(state) {
      if (state.selectedIndex == undefined) return {};
      else return state.students[state.selectedIndex];
    }
  },
   
    mutations: {
        //函数
        selectStudent(state, index) {
            state.selectedIndex = index;
        },

    },
    actions: {
        //异步
    },
    modules: {},

});